//
//  UIScreen+WXUtility.m
//  CommonFramework
//
//  Created by leev on 2017/10/26.
//  Copyright © 2017年 XES. All rights reserved.
//

#import "UIScreen+WXUtility.h"


@implementation UIScreen (WXUtility)

+ (CGFloat)currentScreenWidth
{
    if (!IS_OS_8_OR_LATER)
    {
        switch ([UIApplication sharedApplication].statusBarOrientation)
        {
            case UIInterfaceOrientationPortrait:
            case UIInterfaceOrientationPortraitUpsideDown:
            {
                return [UIScreen mainScreen].bounds.size.width;
            }
                break;
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
            {
                return [UIScreen mainScreen].bounds.size.height;
            }
                break;
            default:
                break;
        }
    }
    else
    {
        return [UIScreen mainScreen].bounds.size.width;
    }
    return 0;
}

+ (CGFloat)currentScreenHeight
{
    if (!IS_OS_8_OR_LATER)
    {
        switch ([UIApplication sharedApplication].statusBarOrientation)
        {
            case UIInterfaceOrientationPortrait:
            case UIInterfaceOrientationPortraitUpsideDown:
            {
                return [UIScreen mainScreen].bounds.size.height;
            }
                break;
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
            {
                return [UIScreen mainScreen].bounds.size.width;
            }
                break;
            default:
                break;
        }
    }
    else
    {
        return [UIScreen mainScreen].bounds.size.height;
    }
    return 0;
}

+ (BOOL)currentScreenIsNarrow
{
    CGFloat screenWidth = ceil(kCurrentScreenWidth);
    if (screenWidth <= 320)
    {
        return YES;
    }
    return NO;
}

+ (BOOL)currentScreenIsIphoneX
{
    CGFloat screenHeight = ceil(kCurrentScreenHeight);
    
    if (screenHeight == 812)
    {
        return YES;
    }
    return NO;
}

@end
